package IC.Types;

import IC.AST.ICClass;

public class ClassType extends Type{
    
	private ICClass icClass;
    private ClassType ancestorClassType;

    public ClassType(ICClass icClass, ClassType ancestor)
    {
        super(icClass.getName());
        this.icClass = icClass;
        ancestorClassType = ancestor;
    }

    public boolean isSub(Type type) 
    {
        	return (type==this) || (ancestorClassType != null && ancestorClassType.isSub(type));
    }
    
	public boolean isRef() 
	{
        return true;
    }

    public String toString() 
    {
    	return String.format("%d: Class: %s %s ", getTypeId(),getTypeName(),(ancestorClassType!=null ? ", ancestor's ID: "+ancestorClassType.getTypeId() : ""));
    }
    
    public ICClass getIcClass() 
    {
        return icClass;
    }
}
